home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / docs / artv1i3a.lha / puzzle.yy < prev   
Text File  |  1995-09-18  |  1KB  |  45 lines

  1. %option noyywrap
  2. %{
  3. #include <stdio.h>
  4. %}
  5. CONS    [BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz]*
  6. %%
  7.  /*grammatical definition for words with consonants occuring in reverse order */
  8. {CONS}u{CONS}o{CONS}i{CONS}e{CONS}a{CONS}   {printf("%s\n",yytext);}
  9.  /*grammatical definition for words with consonants occuring in natural order */
  10. {CONS}a{CONS}e{CONS}i{CONS}o{CONS}u{CONS}   {printf("%s\n",yytext);}
  11. \n    {}
  12. .    {}
  13. %%
  14.  
  15. int main(int argc, char** argv)
  16. {
  17. /* file I/O is the primary focus of this Main function */
  18.   FILE* infile;
  19.   int   filelen, count; 
  20.   char* filename;
  21.   char* num;
  22.  
  23.   /* If the correct command was not entered print correct usage */
  24.   if(argc < 2) {
  25.     fprintf(stderr, "Usage: %s [filename]\n", argv[0]);
  26.     exit(1);
  27.   };
  28.  
  29.   filename = argv[1];
  30.  
  31.   /* If the input file could not be opened give an error message */
  32.   if ((infile = fopen(filename, "r"))==NULL)
  33.     {
  34.       fprintf(stderr, "Error: file %s does not exist\n", filename);
  35.       exit(-1);
  36.     }
  37.   filelen = strlen(filename);
  38.  
  39.   yyin = infile;    /* set so the input of Flex equals the file stream */
  40.   yylex();        /* function called to parse the input for the gramm-
  41.                atical patterns */
  42.  
  43.   fclose(infile);
  44. }
  45.